
$(function(){
	
	
    wx.config({
        debug: false,
        appId: $("#appid").val(),
        timestamp: $("#timestamp").val(),
        nonceStr: $("#nonceStr").val(),
        signature: $("#signature").val(),
        jsApiList: [
            // 所有要调用的 API 都要加到这个列表中
            'getLocation'
        ]
    });
	
	
var tabFlag='common';
$("#common-address-tab").click( function(){
    if(tabFlag == 'history'){
        $("#history-address-tab span").removeClass("text-primary").addClass("text-muted");
        $("#common-address-tab span").removeClass("text-muted").addClass("text-primary");
        $("#common-address-list").show();
        $("#history-address-list").hide();
        commonOffset = 0;
        commonTotal = 0;
        editAddress(3,1,true);
    }
    tabFlag = 'common';
    $("#common-address-list").scrollTop(0);
    
})

$("#history-address-tab").click(function(){
	
    if(tabFlag == 'common'){
    	
        $("#history-address-tab span").removeClass("text-muted").addClass("text-primary");
        $("#common-address-tab span").removeClass("text-primary").addClass("text-muted");
        $("#history-address-list").show();
        $("#common-address-list").hide();
        
        historyOffset = 0;
        historyTotal = 0;
        searchAddress(3,0,true);
    }
    tabFlag = 'history';
    $("#history-address-list").scrollTop(0);
    
})
	$("#homeUnset").click(function (event){
		var address=$("#homeUnset").html();
		var lng=$("#setLng").val();
		var lat=$("#setLat").val();
		$.ajax({
			type : "POST",
			url : "../../address/send",
			dataType : "json",
			data:{
				"address":address,
				"lng":lng,
				"lat":lat,
			},
			success : function(data) {
				if(data.code==200){
					alertSuccess(false,"设置成功!")
				}
			},
			error : function(data) {
				alert("设置失败！");
			}
		});
		event.stopPropagation();
						})
						
	$("#compangUnset").click(function (event){
		var address=$("#homeUnset").html();
		var lng=$("#setLng").val();
		var lat=$("#setLat").val();
		$.ajax({
			type : "POST",
			url : "../../address/send",
			dataType : "json",
			data:{
				"address":address,
				"lng":lng,
				"lat":lat,
			},
			success : function(data) {
				if(data.code==200){
					alertSuccess(false,"设置成功!")
				}
			},
			error : function(data) {
				alert("设置失败！");
			}
		});
		event.stopPropagation();
						})
	
	$.ajax({
		type : "POST",
		url : "../../address/getAddress",
		dataType : "json",
		success : function(data) {
			if(data){
				$("#homeUnset").html(data.address.address).attr("font-size","14px");
				$("#setLng").val(data.address.lng)
				$("#setLat").val(data.address.lat)
				$("#compangUnset").html(data.address2.address)
			    editAddress(3,1,true);
				
			}
		},
		error : function(data) {
			alert("数据加载失败");
		}
	});
function  sendAddress(address,lng,lat){
	$.ajax({
		type : "POST",
		url : "../../address/send",
		dataType : "json",
		data:{
			"address":address,
			"lng":lng,
			"lat":lat,
		},
		success : function(data) {
			if(data.code==200){
				alertSuccess(false,"设置成功!")
			}
		},
		error : function(data) {
			alert("微信配置失败！");
		}
	});
}

var setAddress=[];
$("#common-address li:first,li:eq(1)").click('.address-set',function(){
    setAddress=[];
    setAddress.push($(this).attr("cat"))
    $('.list-container').hide();
    $('section').show();

    $(".loading-des").html("正在努力为您定位当前地址...");
    $("#matte").show();

    setTimeout(function(){
        $("#matte").hide();
    },3000);                    

    wx.hideOptionMenu();
    wx.getLocation({
        type: 'gcj02', // 默认为wgs84的gps坐标，如果要返回直接给openLocation用的火星坐标，可传入'gcj02'
        success: function (res) {
            var latitude = res.latitude; // 纬度，浮点数，范围为90 ~ -90
            var longitude = res.longitude; // 经度，浮点数，范围为180 ~ -180。
            var center = new qq.maps.LatLng(latitude,longitude);
            map = new qq.maps.Map(document.getElementById("map-container"), {
                center: center,
                zoom:15
            });
            marker = new qq.maps.Marker({
                position: center,
                map: map,
                disableDefaultUI: true
            })
            findNear(center);
            initMap();
        }
    });
})

//$("#common-address,#history-address").click('li .address-name',function(){
//    var activeAddress = $(this).closest('li');
//    var lat=activeAddress.attr("lat");
//    var lng=activeAddress.attr("lng");
//    var address=$(this).text();
//    if(lat && lng){
//        $.ajax({
//            type: "POST",
//            async: true,
//            data: {jsondata: JSON.stringify({dests:[{lat: parseFloat(lat), lng: parseFloat(lng), address: address}]})},
//            dataType: "json",
//            url: "../../application/wx/user.php?from=address",
//            success: function(result){
//                if(result.code == 200){
//                    alertSuccess("发送成功",address);
//                }else if(result.code == 401){
//                    refreshToken();
//                    alertWarn(false, "您可能重新绑定了终端, 请重试!");
//                }else{
//                    alertWarn(false, "发送失败");
//                }
//            }
//        })
//    }else{
//        alertWarn("警告", "请先选择一个目的地");
//    }
//})
function findNear(point) {
    //alert(point);
    geocoder = new qq.maps.Geocoder({
        complete: function (result) {
            curcity = result.detail.addressComponents.city;
            var curAddress=result.detail.address;//此地点的完整路径
            var curLatLng=result.detail.location;//此地点的经纬度
            var html = '<li class="list-group-item" address="'+curAddress+'" lat="'+curLatLng.getLat()+'" lng="'+curLatLng.getLng()+'">' +
                '<h5 class="list-group-item-heading">'+curAddress+'</h5>' + '</li>';

            var nearPoints = result.detail.nearPois;
            for (var i = 0; i < nearPoints.length; i++) {
                var poi = nearPoints[i];
                var address = typeof poi.address === 'undefined' ? poi.name : poi.address;
                html = html + '<li class="list-group-item" address="'+address+'" lat="'+poi.latLng.getLat()+'" lng="'+poi.latLng.getLng()+'">' +
                    '<h5 class="list-group-item-heading">'+poi.name+'</h5>' +
                    '<p class="list-group-item-text text-muted"><small>'+address +
                    '</small></p>' + '</li>';
            }
            $('.near-locations').scrollTop(0);
            $('.near-locations').empty().append($(html));
        }
    });

    geocoder.getAddress(point);
}

$('#btn-confirm').click(function(){
	
    var btnConfirm = $(this);
    btnConfirm.button('loading');
    var activeAddress = $(".near-locations li.active");
    var lat=activeAddress.attr("lat");
    var lng=activeAddress.attr("lng");
    var address=activeAddress.attr("address");
    var cat = setAddress[0];
    var data = {name: address, latitude: lat, longitude: lng, cat: cat};
    $.ajax({
        type: "POST",
        async: true,
        data: data,
        dataType: "json",
        url: "../../address/address",
        success: function(result){
            if(result && result.code == 200){
                var licollect = null;
                if(cat == 0){
                    licollect = $("#common-address li:first");
                }else if(cat == 1){
                    licollect = $("#common-address li:eq(1)")
                }
                if(licollect != null){
                    $(licollect).attr({"lng":lng,"lat":lat});
                    $(licollect).find('h4 span small').text(address);
                    $(licollect).find('h4 span').addClass("address-name");
                }
                alertSuccess(false, "设置成功");
                $("#nav-confirm").hide();
                $('section').hide();
                $('.list-container').show();
            }else if(result.code == 401){
                refreshToken();
                alertWarn(false, "您可能重新绑定了终端, 请重试!");
            }else{
                alertWarn(false, "设置失败");
            }
        },
        error: function(){
            alertWarn(false, "设置失败");
        },
        complete: function(){
            btnConfirm.button('reset');
        }
    })
    
})

function alertSuccess(title, content){
    var jc = $.confirm({
        title: title,
        icon: 'glyphicon glyphicon-ok',
        content: content,
        //confirmButtonClass: "btn-success",
        confirmButton: '确定',
        cancelButton: false
    })
    jc.$content.addClass("text-center");
    jc.$content.css({"color":"#9A3036","font-size":"16px"});
};


//$("#common-address").click('li .address-del',function(){
//    var lidel = $(this).closest('li');
//    var addressId = lidel.attr("addressId");
//    $.ajax({
//        type: "GET",
//        async: true,
//        dataType: "json",
//        url: "../../address/set?addressId"+addressId+"&status=3",
//        success: function(result){
//            if(result && result.code == 200){
//                lidel.remove();
//                alertSuccess(false, "删除成功");
//            }
////            else if(result.code == 401){
////                refreshToken();
////                alertWarn(false, "您可能重新绑定了终端, 请重试!");
////            }
//            else{
//                alertWarn(false, "删除失败");
//            }
//        }
//    })
//})



//$("#history-address").click('li .address-collect',function(){
//	
//    var licollect = $(this).closest('li');
//    alert(licollect.addressId)
//    var addressId = licollect.attr("addressId");
//    
//    $.ajax({
//        type: "GET",
//        async: true,
//        dataType: "json",
//        url: "../../address/set?addressId"+addressId+"&status=1",
//        success: function(result){
//            if(result && result.code == 200){
//                licollect.remove();
//                alertSuccess(false, "已成功添加到常用地址中");
//            }
////            else if(result.code == 401){
////                refreshToken();
////                alertWarn(false, "您可能重新绑定了终端, 请重试!");
////            }
//            else{
//                alertWarn(false, "收藏地址失败");
//            }
//        }
//    })
//})
function alertWarn(title, content){
    var jc = $.confirm({
        title: title,
        icon: 'glyphicon glyphicon-warning-sign',
        content: content,
        //confirmButtonClass: "btn-success",
        confirmButton: '关闭',
        cancelButton: false
    })
    jc.$content.addClass("text-center");
    jc.$content.css({"color":"#9A3036","font-size":"16px"});
};
$("#common-address-list").scroll(function(){
    var divHeight = $(this).height();
    var nScrollHeight = $(this)[0].scrollHeight;
    var nScrollTop = $(this)[0].scrollTop;
    if(50+nScrollTop + divHeight >= nScrollHeight) {
        //请求数据
        if(commonOffset < commonTotal){
            $('#address-loading').show();
        }
    }else{
        $('#address-loading').hide();
    }
})

$("#history-address-list").scroll(function(){
    var divHeight = $(this).height();
    var nScrollHeight = $(this)[0].scrollHeight;
    var nScrollTop = $(this)[0].scrollTop;
    if(50+nScrollTop + divHeight >= nScrollHeight) {
        //请求数据
        if(historyOffset < historyTotal){
            $('#address-loading').show();
        }
    }else{
        $('#address-loading').hide();
    }
})

$('#address-loading button').click(function(){
    if(tabFlag == 'common'){
        searchAddress(2,commonOffset,limit,false);
    }else{
        searchAddress(3,historyOffset,limit,false);
    }
    $('#address-loading').hide();
})


function initMap() {
    qq.maps.event.addListener(map, 'dragend', function() {
        centerChanged = true;
    });
    qq.maps.event.addListener(map, 'center_changed', function() {
        if(centerChanged){
            setTimeout(function(){
                findNear(map.getCenter());
            }, 500);
        }
        marker.setPosition(map.getCenter());
        $('#nav-confirm').hide();
    });
}


$("#search").click( function(){
    var key = $("#key-address").val();
    if(key){
        search(key);
    }
    else{
        alertWarn(false, "请输入要查询的地址");
    }
});

$("#key-address").keypress( function(e){
    if(e && e.keyCode==13){ // enter 键
        $("#search").trigger("click");
        //防止回车键提交form
        return false;
    }
});
$("#clear").click(function(){
    $("#key-address").val("");
});

$("#back").click(function(){
    $('section').hide();
    $('.list-container').show();
})

	$('.near-locations').on('click','li',function(){
    centerChanged = false;
    var lat=$(this).attr("lat");
    var lng=$(this).attr("lng");
    var region=new qq.maps.LatLng(lat,lng);

    $(".near-locations li span").remove();
    if($(this).is(".active")){
        $(this).removeClass("active");
        $("#nav-confirm").hide();
    }else{
        map.setCenter(region);
        marker.setPosition(region);
        $(".near-locations li").removeClass("active");
        $(this).addClass("active");
        $(this).html('<span class="badge fa fa-check text-danger"> </span>'+$(this).html());
        $("#nav-confirm").show();
    }
    return false;
});


var commonOffset = 0;
var historyOffset =0;
var commonTotal = 0;
var historyTotal = 0;
var limit = 20;


function editAddress(cat,status,initFlag){
    $.ajax({
        type: "GET",
        async: true,
        dataType: "json",
        url: "../../address/getHistory?cat="+cat+"&status="+status,
        success: function(data){
//            if(addresss && addresss.code == 401){
//                refreshToken();
//                alertWarn(false, "您可能重新绑定了终端, 请重试!");
//            }else if(addresss && addresss.data && addresss.data.results){
                var results = data.address;
                if(results.length > 0){
              if(cat==3){
//              	commonOffset = data['offset']+data['limit'];
//                  commonTotal = data['total'];
                  if(initFlag){
                      $('#common-address li').find('.address-del').closest('li').remove();
                  }
                  $.each(results, function(i){
                      var addressName = results[i]["address"];
                      if(addressName != null && addressName != ""){
                          $("#common-address").append(
//                              '<li class="list-group-item2" addressId='+results[i]["id"] + ' lat="' + results[i]["lat"] +
//                              '" lng="'+results[i]["lng"] + '">' +
//                              '<i></i><img src="/wx/images/address.png"  style="width: 16px;margin-top: -5px;margin-left: 0px;"></img>' +
//                              '<span class="address-name" style="padding-left: 28px;" onclick="destination(\''+results[i]["address"]+'\','+ results[i]["lat"] +','+ results[i]["lng"] +')" >'+results[i]["address"]+'</span>'+' <input type="button" value="删除" onclick="delAddress('+results[i]["id"] + ')" class="pull-right address-del"/></li>'
                         
                              '<li class="list-group-item" addressId='+results[i]["id"] + ' lat="' + results[i]["lat"] +
                              '" lng="'+results[i]["lng"] + '">' +
                              '<i class="fa fa-car pull-left fa-fw text-muted" style="margin-top: 3px;margin-left: 10px; margin-right: 10px"></i>' +
                              '<span class="address-name" onclick="destination(\''+results[i]["address"]+'\','+ results[i]["lat"] +','+ results[i]["lng"] +')">'+results[i]["address"]+'</span>'+' <a href="javascript:void(0)" onclick="delAddress('+results[i]["id"] + ')" class="pull-right address-del">删除</a></li>'
                          
                          
                          
                          )
                      }
                  })
              }  
           
                }
        }
    })	
}

function searchAddress(cat,status,initFlag){
    $.ajax({
        type: "GET",
        async: true,
        dataType: "json",
        url: "../../address/getHistory?cat="+cat+"&status="+status,
        success: function(data){
//            if(addresss && addresss.code == 401){
//                refreshToken();
//                alertWarn(false, "您可能重新绑定了终端, 请重试!");
//            }else if(addresss && addresss.data && addresss.data.results){
                var results = data.address;
                if(results.length > 0){
              if(cat==3){
            	  /*historyOffset = data['offset']+data['limit'];
                historyTotal = data['total'];*/
                if(initFlag){
                    $("#history-address").html('');
                }
                $.each(results, function(i){
                    var addressName = results[i]["address"];
                    if(addressName != null && addressName != ""){
                        $("#history-address").append(
                           /* '<li class="list-group-item2" addressId='+results[i]["id"] + ' lat="' + results[i]["lat"] +
                            '" lng="'+results[i]["lng"] + '">' +
                            '<i></i><img src="/wx/images/address.png"  style="width: 16px;margin-top: -5px;margin-left: -2px;"></img>' +
                            '<span class="address-name" style="padding-left: 28px;" onclick="destination(\''+results[i]["address"]+'\','+ results[i]["lat"] +','+ results[i]["lng"] +')"> '+addressName+' </span>'+' <input type="button"  onclick="a('+results[i]["id"] + ')" class="pull-right address-collect" value="收藏"/> </li>'*/
                        		'<li class="list-group-item" addressId='+results[i]["id"] + ' lat="' + results[i]["lat"] +
                                '" lng="'+results[i]["lng"] + '">' +
                                '<i class="fa fa-car pull-left fa-fw text-muted" style="margin-top: 3px;margin-left: 10px; margin-right: 10px"></i>' +
                                '<span class="address-name" onclick="destination(\''+results[i]["address"]+'\','+ results[i]["lat"] +','+ results[i]["lng"] +')"> '+addressName+' </span>'+' <a href="javascript:void(0)" onclick="collet('+results[i]["id"] + ')" class="pull-right address-collect">收藏</a> </li>'
                        )
                    }
                })
            }
              }  
              else 
            	  if(cat==1){
            	  $.each(results, function(i){
                    var licollect = $("#common-address li:eq(1)");
                    if(licollect != null){
                        $(licollect).attr({"addressId":results[i]['id'],"lng":results[i]['lng'],"lat":results[i]['lat'], "cat": results[i]['cat']});
                        $(licollect).find('h4 span small').text(results[i]["address"]);
                        $(licollect).find('h4 span').addClass("address-name");
                    }
                })
              }else if(cat==2){
//            	commonOffset = data['offset']+data['limit'];
//                commonTotal = data['total'];
                if(initFlag){
                    $('#common-address li').find('.address-del').closest('li').remove();
                }
                $.each(results, function(i){
                    var addressName = results[i]["address"];
                    if(addressName != null && addressName != ""){
                        $("#common-address").append(
                            '<li class="list-group-item" addressId='+results[i]["id"] + ' lat="' + results[i]["lat"] +
                            '" lng="'+results[i]["lng"] + '">' +
                            '<i></i><img src="/wx/images/address.png" style="width: 16px;margin-top: -10px;margin-left: 0px;"></img>' +
                            '<span class="address-name" style="padding-left: 15px;">'+results[i]["name"]+'</span>'+' <a href="#" class="pull-right address-del">删除</a></li>'
                        )
                    }
                })
             
                	
                	
                	
//                    if(cat == 0){
//                        $.each(results, function(i){
//                            var licollect = $("#common-address li:first");
//                            if(licollect != null){
//                                $(licollect).attr({"addressId":results[i]['id'],"lng":results[i]['longitude'],"lat":results[i]['latitude'], "cat": results[i]['cat']});
//                                $(licollect).find('h4 span small').text(results[i]["name"]);
//                                $(licollect).find('h4 span').addClass("address-name");
//                            }
//                        })
//                    }else if(cat == 1){
//                        $.each(results, function(i){
//                            var licollect = $("#common-address li:eq(1)");
//                            if(licollect != null){
//                                $(licollect).attr({"addressId":results[i]['id'],"lng":results[i]['longitude'],"lat":results[i]['latitude'], "cat": results[i]['cat']});
//                                $(licollect).find('h4 span small').text(results[i]["name"]);
//                                $(licollect).find('h4 span').addClass("address-name");
//                            }
//                        })
//                    }else if(cat == 2){
//                        commonOffset = data['offset']+data['limit'];
//                        commonTotal = data['total'];
//                        if(initFlag){
//                            $('#common-address li').find('.address-del').closest('li').remove();
//                        }
//                        $.each(results, function(i){
//                            var addressName = results[i]["name"];
//                            if(addressName != null && addressName != ""){
//                                $("#common-address").append(
//                                    '<li class="list-group-item" addressId='+results[i]["id"] + ' lat="' + results[i]["latitude"] +
//                                    '" lng="'+results[i]["longitude"] + '">' +
//                                    '<i class="fa fa-car pull-left fa-fw text-muted" style="margin-top: 3px;margin-left: 10px; margin-right: 10px"></i>' +
//                                    '<span class="address-name">'+results[i]["name"]+'</span>'+' <a href="#" class="pull-right address-del">删除</a></li>'
//                                )
//                            }
//                        })
//                    }else if(cat == 3){
//                        /*historyOffset = data['offset']+data['limit'];
//                        historyTotal = data['total'];*/
//                        if(initFlag){
//                            $("#history-address").html('');
//                        }
//                        $.each(results, function(i){
//                            var addressName = results[i]["name"];
//                            if(addressName != null && addressName != ""){
//                                $("#history-address").append(
//                                    '<li class="list-group-item" addressId='+results[i]["id"] + ' lat="' + results[i]["latitude"] +
//                                    '" lng="'+results[i]["longitude"] + '">' +
//                                    '<i class="fa fa-car pull-left fa-fw text-muted" style="margin-top: 3px;margin-left: 10px; margin-right: 10px"></i>' +
//                                    '<span class="address-name"> '+addressName+' </span>'+' <a href="#" class="pull-right address-collect">收藏</a> </li>'
//                                )
//                            }
//                        })
//                    }
                }
//            }

        }
    })
}





var geocoder,map,marker = null;

var HEIGHT = $('body').height();
$(window).resize(function() {
    $('body').height(HEIGHT);
});

var curcity="";
var centerChanged=false;

/*function initWxConfig(){
    var url = location.href.split('#')[0];
    $.ajax({
        type: "GET",
        async: true,
        dataType: "json",
        url: "../../application/wx/common.php?m=getWxJsConfig&url="+encodeURIComponent(url),
        success: function(data){
            if(data){
                wxConfig(data);
            }
        },
        error: function(xhr,status,statusText){
            alertWarn(false, "获取微信配置信息失败");
        }
    })
}*/


function search(key){
    var searchService = new qq.maps.SearchService({
        complete: function(result){
            console.log(result);
            var html = '';
            var pois=result.detail.pois;
            if(pois && pois.length > 0){
                for (var i = 0; i < pois.length; i++) {
                    var poi = pois[i];
                    var address = typeof poi.address === 'undefined' ? poi.name : poi.address;
                    html = html + '<li class="list-group-item" address="'+address+'" lat="'+poi.latLng.getLat()+'" lng="'+poi.latLng.getLng()+'">' +
                        '<h5 class="list-group-item-heading">'+poi.name+'</h5>' +
                        '<p class="list-group-item-text text-muted"><small>'+address+
                        '</small></p>' + '</li>';
                }
                $('.near-locations').scrollTop(0);
                $('.near-locations').empty().append($(html));
                $(".near-locations li").first().trigger("click");
            }else{
                alertWarn(false, "没有匹配的地址");
            }
        },
        error: function(){
            alertWarn(false, "没有匹配的地址");
        }
    })
    searchService.setPageIndex(0);//首页
    searchService.setPageCapacity(20);//容量
    searchService.setLocation(curcity);//在某个城市内搜索
    searchService.search(key);//根据地点关键字
};


})
function collet(addressId){
	 $.ajax({
       type: "GET",
       async: true,
       dataType: "json",
       url: "../../address/set?addressId="+addressId+"&status=1",
       success: function(result){
           if(result && result.code == 200){
             //  licollect.remove();
               alertSuccess(false, "已成功添加到常用地址中");
           }
//           else if(result.code == 401){
//               refreshToken();
//               alertWarn(false, "您可能重新绑定了终端, 请重试!");
//           }
           else{
               alertWarn(false, "收藏地址失败");
           }
       }
   })
}

function delAddress(addressId){
//  var lidel = $(this).closest('li');
//  var addressId = lidel.attr("addressId");
  $.ajax({
      type: "GET",
      async: true,
      dataType: "json",
      url: "../../address/set?addressId="+addressId+"&status=3",
      success: function(result){
          if(result && result.code == 200){
//              lidel.remove();
              alertSuccess(false, "删除成功");
          }
//          else if(result.code == 401){
//              refreshToken();
//              alertWarn(false, "您可能重新绑定了终端, 请重试!");
//          }
          else{
              alertWarn(false, "删除失败");
          }
      }
  })
}
function alertSuccess(title, content){
    var jc = $.confirm({
        title: title,
        icon: 'glyphicon glyphicon-ok',
        content: content,
        //confirmButtonClass: "btn-success",
        confirmButton: '确定',
        cancelButton: false
    })
    jc.$content.addClass("text-center");
    jc.$content.css({"color":"#9A3036","font-size":"16px"});
};
function alertWarn(title, content){
    var jc = $.confirm({
        title: title,
        icon: 'glyphicon glyphicon-warning-sign',
        content: content,
        //confirmButtonClass: "btn-success",
        confirmButton: '关闭',
        cancelButton: false
    })
    jc.$content.addClass("text-center");
    jc.$content.css({"color":"#9A3036","font-size":"16px"});
};
function delAddress(addressId){
//    var lidel = $(this).closest('li');
//    var addressId = lidel.attr("addressId");
    $.ajax({
        type: "GET",
        async: true,
        dataType: "json",
        url: "../../address/set?addressId="+addressId+"&status=3",
        success: function(result){
            if(result && result.code == 200){
//                lidel.remove();
                alertSuccess(false, "删除成功");
            }
//            else if(result.code == 401){
//                refreshToken();
//                alertWarn(false, "您可能重新绑定了终端, 请重试!");
//            }
            else{
                alertWarn(false, "删除失败");
            }
        }
    })
}

function destination (address,lat,lng){
	$.ajax({
		type : "POST",
		url : "../../address/send",
		dataType : "json",
		data:{
			"address":address,
			"lng":lng,
			"lat":lat,
		},
		success : function(data) {
			if(data.code==200){
				alertSuccess(false,"设置成功!")
			}
		},
		error : function(data) {
			alert("微信配置失败！");
		}
	});
}






